﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterPage/admin/Supplier.master"
    AutoEventWireup="true" CodeFile="MailBoxList2.aspx.cs" Inherits="Trade_Inbox_MailBoxList2" %>

<%@ MasterType VirtualPath="~/masterPage/admin/Supplier.master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  <%--  
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxLoadingPanel>--%>
<%--    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
      
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rpbNavigator">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rpbNavigator"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone1" LoadingPanelID="RadAjaxLoadingPanel1">
                    </telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>

        </AjaxSettings>
</telerik:RadAjaxManager>--%>

    <telerik:RadWindowManager ID="Singleton" Skin="Outlook" Width="600" Height="430"
        VisibleStatusbar="false" Behaviors="Close,Move, Resize" runat="server" EnableShadow="true">
    </telerik:RadWindowManager>
    <script type="text/javascript">

        function ShowMessage(sender, args) {
            var id = args.getDataKeyValue("NotifyID");
            var wnd = window.radopen("MailBoxDetails.aspx?NotifyID=" + id, null);

            //Get the clicked row 
            var index = args.get_itemIndexHierarchical();
            var item = args.get_tableView().get_dataItems()[index];
            var rowElement = item.get_element();

            //Get coordinates of the row and reposition the window relative to it
            var bounds = $telerik.getBounds(rowElement);
            wnd.moveTo(bounds.x + 120 + index * 10, bounds.y - 180);
        }
    </script>
    <%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>--%>
    <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
        <table>
            <tr>
                <td style="vertical-align: top;">
                    <telerik:RadPanelBar ID="rpbNavigator" runat="server"  OnItemClick="rpbNavigator_ItemClick">
                        <Items>
                            <telerik:RadPanelItem Text="收件箱" Expanded="True" >
                                <Items>
                                    <telerik:RadPanelItem Text="全部邮件 qbxp" Value="All" Selected="true" />
                                    <telerik:RadPanelItem Text="新邮件 (qbwd未读)" Value="Normal"  />
                                    <telerik:RadPanelItem Text="已读邮件 fkxx(fkwd未读)" Value="Business" />
                                    <telerik:RadPanelItem Text="草稿 cgyj" Value="Saved" />
                                    <telerik:RadPanelItem Text="已发送邮件 fsyj" Value="Sent" />
                                    <telerik:RadPanelItem Text="重要邮件 zyyj" Value="Important" />
                                    <telerik:RadPanelItem Text="垃圾邮件 ljyj" Value="Rubbish" />
                                </Items>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelBar>
                </td>
                <td valign="top" width="700">
                    <telerik:RadDockZone ID="RadDockZone1" runat="server" BorderStyle="None">
                        <telerik:RadDock ID="rdList" runat="server" Height="600" Title="我的邮件" CloseText="关闭"
                            CollapseText="收起" DefaultCommands="None" DockMode="Docked" ExpandText="展开" EnableRoundedCorners="true"
                            Collapsed="false" Resizable="false" Pinned="true" Width="600px" EnableDrag="false">
                            <ContentTemplate>
                                <telerik:RadGrid ID="radGridMainlist" AllowPaging="True" AllowSorting="True" DataSourceID="sdsMailList"
                                    runat="server" AutoGenerateColumns="False" AllowMultiRowSelection="True" AllowFilteringByColumn="false"
                                    OnItemCommand="radGridMainlist_ItemCommand">
                                    <ClientSettings Selecting-AllowRowSelect="true" EnableRowHoverStyle="true">
                                        <ClientEvents OnRowSelected="ShowMessage" />
                                    </ClientSettings>
                                    <PagerStyle AlwaysVisible="true" FirstPageToolTip="首页" ShowPagerText="false" PagerTextFormat="{4}  当前{0}/{1}页, 条目({2}-{3})/{5}"
                                        NextPagesToolTip="下页" Mode="NextPrevAndNumeric" PageSizeLabelText="单页数目" PrevPageToolTip="上页"
                                        LastPageToolTip="末页" />
                                    <MasterTableView  DataKeyNames="NotifyID" ClientDataKeyNames="NotifyID" CommandItemDisplay="Top"
                                        ShowHeadersWhenNoRecords="true" NoMasterRecordsText="您目前暂未收到任何信息">
                                        <CommandItemSettings   ShowAddNewRecordButton="true" AddNewRecordText="新建邮件" RefreshText="刷新" />
                                        <Columns>
                                            <telerik:GridButtonColumn Text="删除" CommandName="Delete" ButtonType="ImageButton" 
                                                ConfirmTitle="删除" ConfirmText="确认您要删除该消息吗？">
                                                <HeaderStyle Width="2%" />
                                            </telerik:GridButtonColumn>
                                            <telerik:GridTemplateColumn UniqueName="ImportanceColumn" Groupable="False" HeaderText="重要">
                                                <HeaderStyle Width="30px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="ImportantImage" BorderWidth="0px" CommandName="ChangeImportance"
                                                        ImageUrl='<%# EnableImportant(DataBinder.Eval(Container.DataItem, "Status").ToString(),"ImageUrl") %>'
                                                        AlternateText="重要性" Style="cursor: pointer;" ToolTip='<%# EnableImportant(DataBinder.Eval(Container.DataItem, "Status").ToString(),"AlternateText") %>'
                                                        runat="server"></asp:ImageButton>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn UniqueName="UserName" SortExpression="UserName" HeaderText="发件人" ReadOnly="true"
                                                DataField="UserName">
                                                <HeaderStyle Width="80px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridTemplateColumn UniqueName="Title" Groupable="False" SortExpression="Title"
                                                HeaderText="主题">
                                                <HeaderStyle Width="80px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbtViewDetail" runat="server" CausesValidation="false" Font-Underline="true"
                                                        ForeColor="#0000cc" Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
                                                        CommandName="viewdetail" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                           <telerik:GridTemplateColumn UniqueName="Attachment" Groupable="False" HeaderText="附件">
                                                <HeaderStyle Width="75px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Literal ID="ltlAttachment" Text='<%# (DataBinder.Eval(Container.DataItem, "Attachment").Equals(""))? "无": "是" %>'
                                                        runat="server"></asp:Literal>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn UniqueName="SendDate" SortExpression="SendDate" HeaderText="发送日期" ReadOnly="true"
                                                DataField="SendDate" DataFormatString="{0:d}">
                                                <HeaderStyle Width="75px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridTemplateColumn UniqueName="EventStatus" Groupable="False" HeaderText="信息状态">
                                                <HeaderStyle Width="75px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Literal ID="ltlStatus" Text='<%# EnableRead(DataBinder.Eval(Container.DataItem, "Status").ToString(),null) %>'
                                                        runat="server"></asp:Literal>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn UniqueName="ViewDetails" Groupable="False">
                                                <HeaderStyle Width="35px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbtViewDetails" runat="server" ToolTip="点击查看邮件详情" CausesValidation="false"
                                                        Text="查看" CommandName="viewdetails" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Status").ToString()%>' />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings>
                                        <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
                                    </ClientSettings>
                                </telerik:RadGrid>
                            </ContentTemplate>
                        </telerik:RadDock>
                        <telerik:RadDock ID="rdNewMessage" runat="server" Visible="true" Height="600" Title="新邮件"
                            CloseText="关闭" CollapseText="收起" DefaultCommands="None" DockMode="Docked" ExpandText="展开"
                            EnableRoundedCorners="true" Collapsed="false" Resizable="false" Pinned="true"
                            Width="600px" EnableDrag="false">
                            <ContentTemplate>
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Button ID="btnSend" runat="server" Text="发送" OnClick="btnSend_Click" />
                                        </td>
                                        <td>
                                            <asp:Button ID="btnSave" runat="server" Text="保存草稿" OnClick="btnSave_Click" />&nbsp;<asp:Button
                                                ID="btnCancel" runat="server" Text="取消" CausesValidation="false" OnClick="btnCancel_Click" />
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            收件人
                                        </td>
                                        <td colspan="2">
                                            <telerik:RadComboBox ID="rcbRecipient" runat="server" Width="250px" Height="150px"
                                                LoadingMessage="加载中..."  DataSourceID="sdsCompanyList" DataTextField="CompanyName"
                                                DataValueField="UserID"  EmptyMessage="请选择收件人" EnableAutomaticLoadOnDemand="True" ItemsPerRequest="10"
                                                ShowMoreResultsBox="true" EnableVirtualScrolling="true" AllowCustomText="false">
                                                <Localization NoMatches="未找到" ShowMoreFormatString="{0}/{1}" />
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="rcbRecipient"
                                                 />
                                                 <asp:Label ID="lblMsg" runat="server" EnableViewState="false" ForeColor="Red"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            主题
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbTitle" runat="server" ></asp:TextBox>
                                             <asp:Label ID="lblMsg1" runat="server" EnableViewState="false" ForeColor="Red"></asp:Label>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                     <tr>
                                   
                                    
                                    <td>
                                    添加附件
                                    </td>
                                    <td>
                                        <telerik:RadAsyncUpload ID="radAttachment" runat="server" MaxFileInputsCount="1" ToolTip="文件最大不可超过5MB"
                                            TargetFolder="~/Temporary/uploads/com" AllowedFileExtensions=".rar,.zip,.doc,.pdf,.docx,.ppt,.xls"
                                            MaxFileSize="5120000" ReadOnlyFileInputs="true" ControlObjectsVisibility="None"
                                            Culture="zh-CN">
                                            <Localization Select="浏览" />
                                        </telerik:RadAsyncUpload>
                                        <asp:HyperLink ID="lnkAttachment" Target="_blank" Visible="false" runat="server" />
                                    </td>
                                    <td >
                                        <asp:Button ID="btnSubmitAttachment" runat="server" Text="上传" OnClick="btnSubmitAttachment_Click" />
                                        <asp:Button ID="btnDeleteAttachment" runat="server" Visible="false" Text="删除" OnClick="btnDeleteAttachment_Click" />
                                       
                                    </td>


                                    </tr>
                                    <tr>
                                        <td>
                                            邮件正文
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            <telerik:RadEditor ID="radEditorContent" runat="server" BackColor="White" ContentAreaMode="Div"
                                                Width="650px" ToolsFile="~/App_Data/XML/Editor_BasicTools.xml" LocalizationPath="~/App_GlobalResources"
                                                EditModes="Design" ContentFilters="RemoveScripts" Language="zh-CN">
                                                <FontNames>
                                                    <telerik:EditorFont Value="微软雅黑" />
                                                    <telerik:EditorFont Value="宋体" />
                                                    <telerik:EditorFont Value="Arial" />
                                                    <telerik:EditorFont Value="Times New Roman" />
                                                    <telerik:EditorFont Value="Calibri" />
                                                    <telerik:EditorFont Value="Courier New" />
                                                    <telerik:EditorFont Value="Constantia" />
                                                    <telerik:EditorFont Value="Georgia" />
                                                    <telerik:EditorFont Value="Tahoma" />
                                                    <telerik:EditorFont Value="Verdana" />
                                                </FontNames>
                                            </telerik:RadEditor>
                                           <asp:Literal ID="Updflg" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                </table>
                            </ContentTemplate>
                        </telerik:RadDock>
                    </telerik:RadDockZone>
                </td>
            </tr>
        </table>
    </telerik:RadDockLayout>
    
      <%--  </ContentTemplate>
         </asp:UpdatePanel >--%>
    <asp:SqlDataSource ID="sdsMailList" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="SELECT N.*,U.UserName FROM [XunPan].[dbo].[XPNotification] N,[XunPan].[dbo].[aspnet_Users] U where (N.CreateUserID = CreateUserID AND U.UserId = N.CreateUserID) OR (N.RecipientUserID = CreateUserID AND U.UserId = N.RecipientUserID)  ORDER BY CreateDate desc "
        FilterExpression="{0}" >
        <FilterParameters>
            <asp:Parameter Name="Filter1" Type="String" />
        </FilterParameters>
        <SelectParameters>
            <asp:Parameter Name="CreateUserID" DbType="Guid" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsCompanyList" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="SELECT [CompanyID], [UserID], [CompanyName], [VendorModerateStatus], [BuyerModerateStatus] FROM [XPCompany]   ORDER BY [CompanyName]"
        FilterExpression="[{0}] IN(1, 2)">
        <FilterParameters>
            <asp:Parameter Name="UserRole" Type="String" />
        </FilterParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsViewDetail" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="select N.Title,N.SendDate,N.Status,N.BodyText,U.UserName
        from [XunPan].[dbo].[XPNotification] N,[XunPan].[dbo].[aspnet_Users] U
        where N.CreateUserID = U.UserId  and (N.NotifyID = @NotifyID or N.TargetID = @NotifyID) 
        order by N.CreateDate desc">
        <SelectParameters>
            <asp:Parameter Name="NotifyID" DbType="Guid" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
